<?php

namespace App\Http\Requests\Backend\Setting;

use Illuminate\Foundation\Http\FormRequest;

class SettingHomeImageRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $method = $this->method();
        switch ($method){
            case 'POST':
                return [
                    'img_name' => 'bail|required|string',
//                    'url_set' => 'bail|required',
                    'img_url' => 'bail|required|string',
                    'is_show' => 'in:0,1'
                ];
                break;
            case 'PUT':
                return [
                    'img_name' => 'string',
//                    'url_set' => 'bail|required',
                    'img_url' => 'string',
                ];
                break;
        }

    }

    public function messages()
    {
        return [
            'img_name.required' => '请传递背景名称',
            'img_name.string' => '背景名称应为字符串',
            'img_url.string' => '图片链接应为字符串',
            'img_url.required' => '图片链接必传',
            'is_show.in' => '显示类型传递错误',
        ];
    }
}
